Skip to main content

C Programming for Beginners



Introduction

Programming is a tool to perform various computations with the help of a machine. There are numerous programming languages(coding language) based on need and machine on which program will execute. 


Data Types

In our childhood we learned mathematical numbers and the English alphabet(Data Types). 

In programming languages like in C data are categorized in different groups. 



Function

Functions are the building blocks of a programming language. A function performs a designated task. 

In C language

Syntax to write function without input

main(), add(), nothing() 


Syntax to write function with integer input(add, subtract, multiply, divide)+ no output

void main(int x, int y) 


Syntax to write function with integer input + integer output

int main(int x, int y) 


Syntax to write function with integer input + character output

char main(int x, int y) 



Types of Function




1. User defined function- defined by the programmer or user to perform designated tasks. 


2. Pre defined functions(Library function)- function predefined to perform certain tasks. These functions are used by including their definition in user defined functions. The square root function→ sqrt(x) function is used with input x and this function is defined in the math.h library. 

Similarly, printf() and scanf() → most used pre defined function(defined in stdio.h)



Example of Function

Void main() 

{

}

Here 

main() {    --> start of Program 

} --> end of program



Next program is Printing Hello Program

#include <stdio.h>

Void main() 

{

printf("Hello");

}

In this program printf() is a function with input Hello text. And the print function is defined in stdio.h (#include <stdio.h> → to include the definition print function)



Printing Integer value Program

#include <stdio.h>

Void main() 

{

Int a= 3;     // defining an integer with alphabet a= 3

printf("Number = %d", a);

/* in print function whater written between “ ” will get displayed on output 

The print function replace value after  % (%d will get printed as value of a that is 3) 

*/

}

Comments in C language

// → program will not execute things written after this(single line comment) 

/*...........*/ → multi line comment

Except comments every line ends with a semicolon(;)




Comments

Popular posts from this blog

The Archadian

Every Archadian were looking towards the sky in the hope of sunset and with every passing moment they were afraid of lose. Their fear made them more weak and they lost more life in battle field in-front of large Valvan army. The field was full of blood surrounded by hill on one side and forests from another side. Rest of the two sides covered with two army in front of each other. Archadian vs Valvan The Valvan get more aggressive with their swords flying in the battle field. Finally with sunset, drum sound spread all over the field and war was at end. With sunset over the hills, darkness spread in the field and blood became more red in absence of sun. Alkan, the arrogant Valavn king, ask his solider to return back to tent leaving behind injured and dead Valvan solider in field. Both the army headed towards their tent leaving blood on the earth of Archadians. The Valvan get busy in celebrating their victory in today's battle field. While in Archadian tent, king Arithm order a

Women Personality in Pre Independence Era

  Women Personality in Pre Independence Era Rani Velu Nachiyar(1730-1796)-  She was the first Indian queen(Sivaganga estate) to wage war with the East India Company in India. She regained her kingdom after defeating EICo. with the help of Hyder Ali and many mores. In Tamil she is regarded as Veeramangai .  She was a scholar of French, English, and Urdu languages. Savitribai Phule(1831-1897)-  She raised her voice against caste and gender discrimination. In 1848 she started school in Pune for girl education. She died while serving the Plague affected people.  Pandita Ramabai Sarasvati(1858-1922)-  1st woman to be awarded the titles of Pandita as a Sanskrit scholar and Sarasvati after being examined by the faculty of the University of Calcutta. In 1882, she presented the issue of women education to Hunter Commission . She founded Arya Mahila Samaj(Pune, 1882) . In the same year she wrote Stri Dharma Niti(Morals for Women) book and in 1883 she moved to Britain where she embraced Christia

Surveys in India

  Surveys in India 1. National Family Health Survey 2020-21(NFHS-5) Year 2023 Sex ratio- 1020 Rural sex ratio- 1037 Urban sex ratio- 985 State having highest sex ratio- Kerala(sex ratio- 1084)  Sex ratio at birth- 933 4 types of sex ratios according to the stages of development. Primary Sex Ratio- Sex ratio at Fertilization Secondary Sex Ratio- Sex ratio at Birth  Tertiary Sex Ratio- Sex ratio at maturity Quaternary Sex Ratio- Sex ratio above the age of 60 years