coding pdf
coding pdf
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
----------------------
QUE 1
#include <stdio.h>
#include <stdlib.h>
int main(){
int length =3, breadth=4 ;
int area= length*breadth;
printf(" the area of rectangle is %d", area);
return 0;
}
-----------------------------------------------------
#include <stdio.h>
#include <stdlib.h>
int main(){
int length, breadth;
printf("what is the length of rectangle\n");
scanf("%d",&length);
printf("what is the beadth of rectangle\n");
scanf("%d",& breadth);
printf("the area of rectangle is %d",length*breadth);
return 0;
}
-----------------------------------------------------------------------------------
-----
QUE 2
#include <stdio.h>
#include <stdlib.h>
int main(){
int radius=3;
float pi= 3.14;
printf("the area of circle is %f",pi*radius*radius);
return 0;
}
---------------------------------------
#include <stdio.h>
#include <stdlib.h>
int main()
{
int radius =3;
float pi=3.14;
printf(" the area of circle is %f\n",pi*radius*radius);
int height= 4;
printf(" the volume of circle is %f\n", pi*radius*radius*height);
return 0;
}
------------------------------------------
QUE 3
#include <stdio.h>
#include <stdlib.h>
int main(){
QUE 4
#include <stdio.h>
#include <stdlib.h>
int main(){
int principle=100,rate=20 ,year=20;
int simpleinterest =( principle*rate* year)/100;
printf( " the value of simple interst is %d", simpleinterest);
return 0;
}
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-------------------
CHAPTER 2 PRACTICE SET
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
----------------
QUE 1
1) invalid because b is not defined previously
2) valid tooo hai but zero return karega
3) invalid because ek single char ke andar bhaut sare character defined kar
diye ess liye
------------------------------------------
QUE 2
doule wala data type return karega , float mai presesion kamm hota ess liye double
data type hoga
-----------------------------
QUE3
#include <stdio.h>
#include <stdlib.h>
int main()
{ int num;
printf("enter the number\n");
scanf("%d", & num);
printf(" divisibility tes return %d\n ",num%97);
return 0;
}
O/P agar divisible hoga too zero return karega baki kuch bhi return kar sakta hai'
------------------------------------------------------
QUE4
3* 2/3- 3+1 =6/3-3+1= 2-3+1= 0
-----------------------------------------------------------------------------------
-----------------------------------------------
QUE 5
float and int sath mai hai too int hii denge so option (B) is coorect answer
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-------------------
CHAPTER 3 PRACTICE SET
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-------------------
SWITCH CASE CONTROL INTRUCTION EXAMPLE
#include <stdio.h>
#include <stdlib.h>
int main (){
int rating;
printf("enter your rating(1-5)\n ");
scanf("%d",&rating);
switch(rating){
case 1 :
printf("your rating is 1\n");
break;
case 2 :
printf("your rating is 2\n");
break;
case 3 :
printf("your rating is 3\n");
break;
case 4 :
printf("your rating is 4\n");
break;
case 5 :
printf("your rating is 5\n");
break;
default :
printf(" invalid rating");
break;
}
return 0;
}
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
---------------------------------------
QUE1
it will " I am 11" becaus single = hai na ki double ==
---------------------------------------
QUE2
#include <stdio.h>
#include <stdlib.h>
int main()
{
int physics , chemistry, maths;
float total;
printf("enter your physics marks\n");
scanf("%d",& physics);
printf("enter your chemistry marks\n");
scanf("%d",& chemistry);
printf("enter your maths marks\n");
scanf("%d",& maths);
} else{
printf(" you are pass and your total percentage is %f\n", total);
}
return 0;
}
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
----
QUE 3
#include <stdlib.h>
#include <stdio.h>
int main()
{
int tax= 0, income;
printf("enter your income\n");
scanf("%d",&income);
if (income>=250000 && income <=500000){
tax+ tax+ 0.05*(income-250000);
}
if (income>=500000 && income <= 1000000)
{
tax= tax + 0.20 *( income-500000);
}
if (income>=1000000 )
{
tax= tax + 0.30 *( income-1000000);
}
printf("your net income tax to be paid is %d\n", tax);
return 0;
}
-----------------------------------------------------------------------------------
--------------------------------------------------------------------
QUE 5
#include <stdio.h>
#include <stdlib.h>
#include <stdio.h>
int main()
{
char ch;
printf(" enter the character\n");
scanf("%d",& ch);
if (ch<=122 && ch>=97)
{
printf(" it is lowercase");
}
else {
printf(" it is not lower case");
}
return 0;
}
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
------------------- CAHPTER 4 PRACTICE
SET
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------------
------------------
QUE 2
#include <stdio.h>
#include <stdlib.h>
int main()
{
printf("multiplacation table of 10\n");
for(int i=10;i;i--){
return 0;
}
-------------------------------------------------------------------------------
QUE 1
#include <stdio.h>
#include <stdlib.h>
int main()
{
int i, n;
printf(" table of any number\n");
printf(" number of table which you want\n");
scanf("%d",&n);
for(i=1;i<=10;i++){
return 0;
}
-------------------------------- OR
#include <stdio.h>
#include <stdlib.h>
int main()
{
int i, sum=0,n=10;
While(i<=n){
sum+=i;
i++;}
printf("the value of sum from 1to 10 is %d", sum);
return 0;
}
----------------------------------------------
QUE7
#include <stdio.h>
#include <stdlib.h>
int main()
{ int i=0,sum;
for(i=0;i<=10;i++)
{
sum= sum+ 8*i;
printf( "the table of 8 is 8*%d=%d\n",i,8*i);
printf(" the sum of table of 8 is %d\n",sum);
}
return 0;
}
---------------------------------------------------
QUE 8
#include <stdio.h>
#include <stdlib.h>
int main()
{
int i=0,n=3,factorial=1;
for(i=1;i<=n;i++){
factorial*=i;
}
printf("the value of factorial %d is %d",n,factorial);
return 0;
}
----------------------------------------------------------------------
QUE 9
#include <stdio.h>
#include <stdlib.h>
int main()
{
int n=45,prime=0;
for(int i=2;i<4;i++){
if(n%i==0){
prime=1;
break;
}
}
if prime==1{
printf("this is not a prime number");
}
else{
printf("this isa prime number");
}
return 0;
}
--------------------------------------------------------------