C Programming

#include<stdio.h>
#include<conio.h>
int main()

{
int age, mark;//here mark veriable not declare so garbage value print
age=18;
printf("%d",age);
printf("\n%d",mark);//'\n' for new line
return 0;
}

5-2)

#include<stdio.h>

#include<conio.h>

int main()



{
int age=20, mark=0;//here mark veriable
age=25;//here overwrit 20 to 25
mark=600;//here overwrit 0 to 600
printf("%d",age);// hre format specifayer %d
printf("\n%d",mark);
return 0;
};
5-3)

#include<stdio.h>

#include<conio.h>

int main()



{//remember that befor use a variable must declare it.
int age=20, mark=0;//here mark age are intiger type veriables 
char letter='A';//here letter is character type veriable 
float average=55.20;//here average is float type veriable
age=25;//here overwrit 20 to 25
mark=600;//here overwrit 0 to 600
printf("Age=%d\n",age);// here format specifayer %d for int
printf("mark=%d",mark);
printf("\nLetter=%c",letter);// here format specifayer %c for char
printf("\naverage=%f",average);// here format specifayer %f for float

return 0;
};

5-4)
//about printf function in details
//printf function some argument pass and return
// syntax int printf("format , variables);
#include<stdio.h>
#include<conio.h>
int main()

{//remember that befor use a variable must declare it.
int age;
int counter;
printf("Abujafar Khan\n");//here not refer variable so that not write another part
// so type format
printf("Abujafar Khan & My age is %d",age);//,age or 30
printf(" My age is %d",30);//here we are refer age virable
//or we are write  value direct here
printf(" & My Gender is %c%c%c%c",'M','a','l','e');//we are also write direct char
//how to printout  a name between double quote
printf("\"Abujafar Khan\"\n");//here we are scape double quote meaning
//here use escape sequence Ex- \"Abujafar Khan\" 
//also we create a new line or tab through the scape sequence \t,\n
// T for Tab , N for Line
counter=printf("learning Education");//here printf function which values return
//we store them in counter variable
printf(" counter= %d",counter);


return 0;

};

9-1)
#include<stdio.h>
#include<conio.h>
int main()

{
int no1, no2,resulte;//
no1=25;
no2=5;
resulte=no1+no2;
//ADDITION
//printf("%d+%d =%d,",20,30,20+30); OR printf("%d",resulte);
printf("2nd--resulte=%d\n",resulte);
//or
printf("3rd%d+%d =%d\n",25,5,25+5);
//or
printf("4th--no1=%d+ no2=%d resulte=%d\n",no1,no2,no1+no2);

resulte=no1-no2;
//SUBTRACTION
//printf("%d-%d =%d,",20,30,20-30); OR printf("%d",resulte);
printf("2nd--resulte=%d\n",resulte);
//or
printf("3rd%d-%d =%d\n",25,5,25-5);
//or
printf("4th--no1=%d-no2=%d resulte=%d\n",no1,no2,no1-no2);

//MULTIPLICATION
printf("5th--no1=%d* no2=%d resulte=%d\n",no1,no2,no1*no2);
resulte=no1*no2;
printf("6th--no1=%d * no2=%d resulte=%d\n",no1,no2,resulte);
//Or
printf("6th--no1=%d * no2=%d resulte=%d\n",25,5,resulte);
//DIVISION
resulte=no1/no2;
printf("7th--no1=%d/no2=%d resulte=%d\n",no1,no2,resulte);
//or
printf("8th--no1=%d/no2=%d resulte=%d\n",no1,no2,no1/no2);
//Or
printf("9th--no1=%d * no2=%d resulte=%d\n",60,6,60/6);
return 0;
}

10-1)
#include<stdio.h>
#include<conio.h>
int main()
//Use of Relational operator   part 10
//fales value is 0
//true value is 1
{
int n1=30;
int n2=30;
int resulte;
resulte=n1<n2;//lessthan
printf("%d<%d is %d\n",n1,n2,resulte);
//here n1 value graterthan n2 value so resulte is fales, or zero(0)

resulte=n1>n2;//Graterthan
printf("%d<%d is %d\n",n1,n2,resulte);
//here n1 value graterthan n2 value so resulte is true, or one(1)

resulte=n1>=n2;//Graterthan equal
printf("%d>=%d is %d\n",n1,n2,resulte);

resulte=n1==n2;//equal equal
printf("%d==%d is %d\n",n1,n2,resulte);

resulte=n1<=n2;//lessthan equal
printf("%d<=%d is %d\n",n1,n2,resulte);

resulte=n1!=n2;//not equal
//here n1 is not equal to n2 so the resulte is fales or zero(0) 
printf("%d!=%d is %d",n1,n2,resulte);
return 0;

}

10-2)
#include<stdio.h>
#include<conio.h>
int main()
//Use of logical operator   part 10
//fales value is 0
//true value is 1
{
int n1=100;
int n2=20;
int resulte;
resulte=(n1>0)  && (n1<101);//(n1>0)  && (n1<100)
//and operator if two condition are true than resulte is ture otherwise fales
printf(" %d\n",resulte);
//Or operator if all condition are fales than resulte is fales otherwise true
resulte=(n1<0)  || (n1>200);//(n1>0)  || (n1<200)
printf(" %d\n",resulte);
n1=1;
resulte=!n1;
//!n1 means if n1 value is 0 than fales otherwise number is  true(1)
//here n1 value is 1 so
printf(" %d",n1);
return 0;

}

11-1)
#include<stdio.h>
#include<conio.h>
int main()
{int x=10;
int y;
//++ increment ,-- decrement
printf("x before increment =%d\n",x);
y=++x;
//prefix ++x first increment than use in the expresion
//postfix x++ which value has x first use in the expresion then increment
printf("x=%d\n",x);//11
printf("y=%d",y);//11
return 0;

12-1)
#include<stdio.h>
#include<conio.h>
int main()
{
//selection statement or decision control statement
//in c pro two type of statement one is if statement other is switch staement
//now cosiderate if statement
int age;
printf("Please enter your age\n");
scanf("%d",&age);
if(age>=18)
{printf("you are adult so please get in to dance club\n");
}
printf("programing in fun");
return 0;

}
12-2)

#include<stdio.h>

#include<conio.h>
int main()
{
//selection statement or decision control statement
//in c pro two type of statement one is if statement other is switch staement
//now cosiderate if statement
int age;
printf("Please enter your age\n");
scanf("%d",&age);
if(age>=18)
{printf("you are adult so please get in to dance club\n");
}
else{printf("you are kid so please go home\n");
}
printf("programing in fun");
return 0;
}
12-3)

#include<stdio.h>

#include<conio.h>
int main()
{
//selection statement or decision control statement
//in c pro two type of statement one is if statement other is switch staement
//now cosiderate if statement
int age;
printf("Please enter your age\n");
scanf("%d",&age);
if(age>=18)
{printf("you are adult so please get in to dance club\n");
}else if(age>=6)
{printf("yor are go to school");
}else if(age<=6){printf("you are go to Anganwadi");
}//so how many times want you use  else if 
else

printf("programing in fun");
return 0;
}
12-4)

13-1)

#include<stdio.h>

#include<conio.h>
int main()
//ternary operator
//syntax-  expression (condission part) ? expression1 (truepart):expression2 (falespart)
{ int age;
printf("Enter your age\n");
scanf("%d",&age);//if not use &(read operator) programe stop
age >= 18 ? printf("your are adult") : printf("you are minor");
//age >= 18 also use logical operator here if you want
return 0;
}

14-1)


#include<stdio.h>

#include<conio.h>
int main()
//through the loop we are repited statement 
//in C programming three types of loop
//while loop, do while loop , for loop
//syntex while(expression){  }
{
int counter=1;
while(counter <=5)
{printf("%d----->Abujar Khan\n",counter);
counter++;//if not counter varible not increment the exquetion running
}

 printf("you are minor");

return 0;
}
14-2)

#include<stdio.h>

#include<conio.h>
int main()
//through the loop we are repited statement 
//in C programming three types of loop
//while loop, do while loop , for loop
//syntex while(expression){  }
{
int counter=1;
while(1)// in c true is 1 and fales is 0
{printf("%d----->Abujar Khan\n",counter);
counter++;//if not counter varible not increment the exquetion running
}

return 0;
}




No comments: