codizzmafia banner

Codizzmafia | Programming related Articles and News.


c programming examples ,c programming examples pdf ,c programming examples for beginners ,c programming examples sanfoundry ,c programming examples on fun,ctions ,c programming examples on loops ,c programming examples with output in hindi ,c programming examples for pra,cti,ce ,c programming examples addition ,c programming examples and solutions ,c programming examples arrays ,c programming examples advan,ced ,c programming examples and solutions pdf ,c programming algorithms examples ,c programming array examples pdf ,c programming arithmeti,c examples ,c programming examples basi,c ,c programming examples book ,c programming examples bitwise operations ,c programming examples book pdf ,c programming examples binary sear,ch ,c programming examples bu,cket sort ,c programming basi,c examples pdf ,c programming boolean example ,c programming example ,codes ,c programming ,code examples pdf ,c programming ,char example ,c programming ,class example ,c programming ,curl example ,c programming ,cout example ,c programming ,case example ,c programming ,chara,cter example ,c programming examples dev ,c++ ,c programming examples do while loop ,c programming examples download ,c programming examples download pdf ,c programming examples de,cimal to binary ,c programming diffi,cult examples ,c programming database examples ,c programming different examples ,c programming easy examples ,c programming enum examples ,c programming errno example ,c programming exe,c example ,c programming exit example ,c programming examples if else statement ,c programming examples with explanation pdf ,c programming examples using if else ,c programming examples for interview ,c programming examples for beginners pdf ,c programming examples for loop ,c programming examples fa,ctorial ,c programming examples for array ,c programming examples for fun,ctions ,c programming examples github ,c programming examples geeksforgeeks ,c programming examples graphi,cs ,c programming games examples ,c programming graphi,cs examples with output ,c programming examples on puzzles & games ,c gui programming examples goto in ,c programming examples ,c programming examples hello world ,c programming examples hindi ,c programming examples in hindi pdf ,c programming examples file handling ,c programming time.h examples ,c programming math.h examples ,c programming examples of file handling pdf ,c programming examples interview questions ,c programming examples in hindi ,c programming examples if statement ,c programming string examples ,c programming examples in linux ,c programming examples in loops ,c programming examples javatpoint ,c programming examples on keywords keil ,c programming examples ,c programming examples loops ,c programming examples list ,c programming examples linked list ,c programming loop examples pdf ,c programming languages examples ,c programming examples while loop ,c programming examples using linux operating systems ,c programming examples on logi,cal operators ,c programming examples matrix ,c-programming-examples-mathemati,cal-fun,ctions ,c programming ma,cro examples ,c programming mallo,c example ,c programming menu example ,c programming modulus example ,c programming makefile example ,c programming memset example ,c programming examples+nested for loop ,c programming n,curses example ,c programming examples prime number ,c programming random number example ,c programming notes with examples pdf ,c programming number pattern examples ,c sharp .net programming examples ,c programming notes with examples ,c programming examples of stru,cture ,c programming examples on strings ,c programming examples on arrays ,c programming examples of patterns ,c programming examples on operators ,c programming examples on mathemati,cal fun,ctions ,c programming examples programiz ,c programming examples programs ,c programming examples patterns ,c programming examples pdf books ,c programming examples pointers ,c programming examples pyramid ,c programming examples questions ,c programming queue examples ,c programming qsort example message queue ,c programming examples ,c programming example questions ,c program simple questions ,c programming re,cursion examples ,c programming fun,ction return array ,c programming fun,ction return multiple values ,c programming fun,ction return string ,c programming fun,ction return value ,c programming fun,ction return ,c programming fun,ction return stru,ct ,c programming fun,ction returns address of lo,cal variable ,c programming examples swit,ch ,case ,c programming examples sum of digits ,c programming examples stru,ctures ,c programming examples string ,c programming examples simple ,c programming examples star ,c programming examples simplified ,c programming examples tutorialspoint ,c programming examples two dimensional array ,c programming examples tutorial ,c programming triangle examples ,c programming test examples ,c programming tutorial examples pdf ,c programming tough examples ,c programming thread example ,c programming examples using fun,ctions ,c programming examples using swit,ch ,case ,c programming examples using pointers ,c programming examples using ,conditional operators ,c programming examples using array pdf ,c programming examples using re,cursion ,c programming variables examples ,c programming examples with output video volatile ,c programming examples void in ,c programming examples ,c programming variables ,c programming variables types ,c programming examples with output pdf ,c programming examples with explanation ,c programming examples with output ,c programming examples with solutions pdf ,c programming examples with algorithm ,c programming examples with solutions ,c programming examples youtube fun,ctions in ,c programming with examples youtube ,c program in youtube ,c program youtube ,c programming basi,cs youtube embedded ,c programming examples pdf 1000 ,c programming examples pdf ,c programming fun,ctions examples pdf 8051 ,c programming examples pdf 100 ,c programming examples pdf ,c programing examples with answers pdf ,c programming all examples pdf ,c programming algorithms examples pdf advan,ced ,c programming example pdf arm pro,cessor ,c programming examples pdf 2d array in ,c programming examples pdf ,c sharp programming examples for beginners pdf embedded ,c programming basi,cs with examples pdf ,c programming tutorial for beginners with examples pdf free download ,c programs pdf book ,c programming examples pdf download ,c programming ,con,cepts with examples pdf ,c programming sour,ce ,code examples pdf swit,ch ,case in ,c programming examples pdf ,c programming ,code pdf ,c ,code examples pdf ,c programming examples pdf free download advan,ced ,c programming by example pdf free download advan,ced ,c programming by example pdf download dynami,c memory allo,cation in ,c programming examples pdf ,c programs pdf download 8051 embedded ,c programming examples pdf nested if else in ,c programming examples pdf ,c programs with explanation pdf ,c programming examples output pdf free download ,c programming examples with flow,chart pdf ,c programming examples on fun,ctions pdf files in ,c programming examples pdf ,c programming for loop examples pdf graphi,cs programming in ,c examples pdf graphi,cs programming in ,c pdf graphi,cs programming in ,c language pdf graphi,cs programming in ,c examples ,c programming if example pdf array in ,c programming examples pdf fun,ction in ,c programming examples pdf stru,cture in ,c programming examples pdf pointer in ,c programming examples pdf string in ,c programming examples pdf ,c programming language examples pdf ,c programming while loop examples pdf learn ,c programming with examples pdf algorithm in ,c programming language examples pdf ,c programming loop examples ,c programming loop example


Example -1

AIM:
Write a C program that will output this passage by Michael Singer. Make sure your output looks exactly as shown here (including spacing, line breaks,punctuation, and the title and author). Use Required Escape Sequence and ASCII Value.

There are three shapes in the output: Smiling Face, Diamond & Heart.
The ASCII Value for Smiling face is 1.
The ASCII Value for Diamond is is 4.
The ASCII Value for Heart is is 3.

PROGRAM  CODE:

#include<stdio.h>
#include<conio.h>
int main()
{
char a=1,b=4,c=3;
clrscr();
printf("%c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c\n",a,b,c,a,b,c,a,b,c,a,b,c,a,b,c,a,b,c,a,b,c,a,b,c,a,b,c,a,b,c,a,b,c,a,b,c,a);
printf("%c",b);
printf("\"If you are resisting something,you are feeling it.\t\t\t");
printf("%c\n",b);
printf("%c",c);
printf("\tAny energy you fight, you are feeding it.\t\t\t");
printf("%c\n",c);
printf("%c",a);
printf("\t\tIf you are pushing something away,\t\t\t");
printf("%c\n",a);
printf("%c",b);
printf("\t\t\tYou are inviting it to stay.\"by Michel singer.  ");
printf("%c\n",b);
printf("%c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c %c\n",a,b,c,a,b,c,a,b,c,a,b,c,a,b,c,a,b,c,a,b,c,a,b,c,a,b,c,a,b,c,a,b,c,a,b,c,a);
getch();
return 0;
}


""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

Example-2
AIM:
Ramesh‟s basic salary is input through the keyboard. His dearness allowance is 40% of basic salary, and house rent allowance is 20% of basic salary. Write a program to calculate his gross salary.

PROGRAM  CODE:

#include<stdio.h>
#include<conio.h>
#include<math.h>
int main()
{
int s,da,ha,ts;
printf("please enter ramesh's salary\n");
scanf("%d",&s);
da=(s*40)/100;
printf("ramesh's dearness allowance is %d\n",da);
ha=(s*20)/100;
printf("ramesh's house rant allowance is %d\n",ha);
ts=s+ha+da;
printf("ramesh total salary is %d",ts);
getch();
return 0;
}

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""


Example-3
AIM:
Write a program to calculate area of two circle. (πr2). Use Preprocessor directive named macro expansion for the symbol π (Symbolic Constant) without argument and with argument. Use typedef to rename the floatdatatype.

PROGRAM  CODE:
#include<stdio.h>
 #include<conio.h>
#define PI 3.14
 #define PERIMETER(r) 2*PI*r
 void main()
{  
 typedef float circle;   
circle r1,r2,a1,a2;
printf("\n\n\n\tEnter the value of r1:");  
 scanf("%f",&r1);   
printf("\tEnter the value of r2:");   
scanf("%f",&r2);                   
a1=PI*r1*r1;                   
a2=PI*r2*r2;   
printf("\tArea of radius %f is %.2f.\n",r1,a1);  
 printf("\tArea of radius %f is %.2f.\n",r2,a2);   
printf("\tPerimeter of r1 is %2f\n",PERIMETER(r1));   
printf("\tPerimeter of r2 is %2f",PERIMETER(r2));   
getch();
}

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""


Example-4
AIM:
Write a program to do following:
Input an amount and convert it into rupees and paisa. (For Ex. 25.67Rs = 25 Rs and 67 Paisa).(Implicit type Conversion)

PROGRAM  CODE:
#include<stdio.h>
#include<conio.h>
int main()
{
int R,P;
float amount;
clrscr();
printf("enter the amount\n");
scanf("%f",&amount);
R=amount;
printf("your Rupees is %d\n",R);
P=(amount-R)*100;
printf("your paisa is %d\n",P);
getch();
return 0;
}

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""


Example-5
AIM:
While purchasing certain items, a discount of 10% is offered if the quantity purchased is more than 1000.If quantity and price per item are input through the keyboard, write a program to calculate the total expenses. Use Simple If statement.

PROGRAM  CODE:

#include<stdio.h>
#include<conio.h>
int main()
{
int n,ppr;
float expenses;
printf("please enter a number of item you perchased\n");
scanf("%d",&n);
printf("please enter price per item\n");
scanf("%d",&ppr);
if(n>1000)
{
expenses=0.9*ppr*n;
printf("your total expenses is %f\n",expenses);
}
else
{
expenses=(ppr*n);
printf("your total expenses is %f\n",expenses);
}
getch();
return 0;

}

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""


Example-6
AIM:
Given three points (x1, y1), (x2, y2) and (x3, y3), write a program to check if all the three points fall on one straight line. Use fabs() function of <maths.h>header file. Use if…elsestatement

PROGRAM  CODE:
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int x1,x2,x3,y1,y2,y3;
float s1,s2:
printf("\nEnter x1 ");
scanf("%d",&x1);
printf("Enter y1 ");
scanf("%d",&y1);
printf("Enter x2 ");
scanf("%d",&x2);
printf("Enter y2 ");
scanf("%d",&y2);
printf("Enter x3 ");
scanf("%d",&x3);
printf("Enter y3 ");
scanf("%d",&y3);
 s1=fabs((y2-y1)/(x2-x1));
 s2=fabs((y3-y2)/(x3-x2));
if(s1==s2)
{
printf("The points are colinear.");
            }
else
{
printf("The points  non colinear .");
              }
getch();
}

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""


Example-7
AIM:
If the three sides of a triangle are entered through the keyboard, write a program to check whether the triangle is valid or not. The triangle is valid if the sum of two sides is greater than the largest of the three sides. Use nested if…else statement.

PROGRAM  CODE:

#include<stdio.h>
#include<conio.h>
void main()
{
int s1,s2,s3;

printf("\nEnter three sides of triangle");
scanf("\n%d %d %d",&s1,&s2,&s3);
if((s1+s2)>s3)
{
if((s2+s3>s1))
{
if((s3+s1)>s2)
{
printf("The triangle is valid.");
 }
}
}
else
{
printf("The triangle is not valid.");
}
getch();
}

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""


Example-8
AIM:
An Insurance company follows following rules to calculate premium.
(1) If a person‟s health is excellent and the person is between 25 and 35 years of age and lives in a city and is a male then the premium is Rs. 4 per thousand and his policy amount cannot exceed Rs. 2 lakhs.
(2) If a person satisfies all the above conditions except that the gender is female then the premium is Rs. 3 per thousand and her policy amount cannot exceed Rs. 1 lakh.
(3) If a person‟s health is poor and the person is between 25 and 35 years of age and lives in a village and is a male then the premium is Rs. 6 per thousand and his policy cannot exceed Rs. 10,000.
(4) In all other cases the person is not insured. Write a program to output whether the person should be insured or not, his/her premium rate and maximum amount for which he/she can be
insured. Use Else…if Ladder.

PROGRAM-CODE:

#include<stdio.h>
#include<conio.h>
int main()
{
char health,place,gender;
int age;
printf("please enter your health like for excelant press e and for poor press p\n");
scanf("%c",&health);
fflush(stdin);
printf("please enter your place like for city press c and for village press v\n");
scanf("%c",&place);
fflush(stdin);
printf("please enter your gender like for male press m and for female press f\n");
scanf("%c",&gender);
fflush(stdin);
printf("please enter your age\n");
scanf("%d",&age);
if((health=='e'||health=='E')&&(place=='c'||place=='C')&&(gender=='m'||gender=='M')&&(age>=25)&&(age<=35))
{
printf("the primium is rs 4 per thousand and his policy amount can not exceed rs 2 lakh\n");
}
if((health=='e'||health=='E')&&(place=='c'||place=='C')&&(gender=='f'||gender=='F')&&(age>=25)&&(age<=35))
{
printf("the primium is rs 3 per thousand and his policy amount can not exceed rs 1 lakh\n");
}
if((health=='p'||health=='P')&&(place=='v'||place=='V')&&(gender=='m'||gender=='M')&&(age>=25)&&(age<=35))
{
printf("the primium is rs 6 per thousand and his policy amount can not exceed rs 10000\n");
}
else
{
printf("u r not valid for policy\n");
}
getch();
return 0;
}

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""


Example-9
AIM:
Write a program to input a character using getchar() and print the character using putchar() and check the character category. Also convert uppercase alphabet to lower case and vice versa. (Use Character Test Functions : isalnum(), isalpha(), isdigit(), islower(), isprint(), ispunct(), isspace(), isupper()) and (toupper() & tolower()) of <ctype.h> header file.

PROGRAM  CODE:

#include<stdio.h>
#include<conio.h>
#include<ctype.h>
void main()
{
char a;
            
printf("\nEnter your character ");
a=getchar();
if((isalnum(a))&&(isprint(a)))
{
printf("\nThe input is printable\n");
if(isalpha(a))
{
printf("\nThe character is an alphabet\n");
if(isupper(a))
{
printf("\nThe character is in upper case\n");
a=tolower(a);
putchar(a);
}
else if(islower(a))
{
printf("\nThe character is in lower case\n");
a=toupper(a);
putchar(a);
}
 }
if(isdigit(a))
 {
printf("\nThe character is digit.");
putchar(a);
 }
}
else if((ispunct(a))&&(isprint(a)))
{
printf("\nThe input is a punctuation.");
putchar(a);
}
else if((isspace(a))&&(isprint(a)))
{
printf("\nThe input is a blank space and not printable.");
putchar(a);
}
getch();
}

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""


Example-10
AIM:
Write a program to find the grace marks for a student using Switch Statement. The user should enter the class obtained by the student and the number of subjects he has failed in.
1. If the student gets first class and the number of subjects he failed in is greater than 3, then he does not get any grace. If the number of subjects he failed in is less than or equal to 3 then the grace is of 5 marks per subject.
2. If the student gets second class and the number of subjects he failed in is greater than 2, then he does not get any grace. If the number of subjects he failed in is less than or equal to 2 then the grace is of 4 marks per subject.
3. If the student gets third class and the number of subjects he failed in is greater than 1, then he does not get any grace. If the number of subjects he failed in is equal to 1 then the grace is of 5 marks per subject.

PROGRAM  CODE:
#include<stdio.h>
#include<conio.h>
void main()
{
Int fail_sub;
char Class;
clrscr();
 printf("\nEnter class : ");
scanf("%c",&Class);
printf("\nEnter number of subjects stdent is failing : ");
scanf("%d",&fail_sub);
switch(Class)
{
case 'f': if(fail_sub>3)
{
printf("\nNo grace marks given");
}
else if(fail_sub<=3)
{
printf("\n5 grace marks per subject are given");
}

break;
case 's':      if(fail_sub>2)
{
printf("\nNo grace marks given.");
}
else if(fail_sub<=2)
{
printf("\n4 grace marks per subject are given.");
}
break;
case 't':        if(fail_sub>1)
{
printf("\nNo grace marks given.");
}
else if(fail_sub>=1)
{
printf("5 grace marks per subject are given.");
}
break;
default:     
    printf("Please enter correctly.");
}
getch();
}


Thank YOU.

Post a Comment

Previous Post Next Post

native_banner