13. Program to accept rollnumber and marks of three subjects from user and print total marks, average and grade.
#include<stdio.h>
#include<conio.h>
void main()
{
int RollNum, m1, m2, m3, total;
float avg;
clrscr();
printf("Enter Roll Number : ");
scanf("%d",&RollNum);
printf("Enter marks for three subjects : ");
scanf("%d %d %d", &m1, &m2, &m3);
total = m1 + m2 + m3;
avg = total / 3.0;
printf("\nTotal is : %d", total);
printf("\nAverage is : %5.2f", avg);
if(avg>80)
printf("\nGrade : A");
else if((avg>60)&&(avg<=80))
printf("\nGrade : B");
else if((avg>40)&&(avg<=60))
printf("\nGrade : C");
else if((avg>=33)&&(avg<=40)
printf("\nGrade : D");
else
printf("\nGrade : Fail");
getch();
}
@programming_and_coding
#include<stdio.h>
#include<conio.h>
void main()
{
int RollNum, m1, m2, m3, total;
float avg;
clrscr();
printf("Enter Roll Number : ");
scanf("%d",&RollNum);
printf("Enter marks for three subjects : ");
scanf("%d %d %d", &m1, &m2, &m3);
total = m1 + m2 + m3;
avg = total / 3.0;
printf("\nTotal is : %d", total);
printf("\nAverage is : %5.2f", avg);
if(avg>80)
printf("\nGrade : A");
else if((avg>60)&&(avg<=80))
printf("\nGrade : B");
else if((avg>40)&&(avg<=60))
printf("\nGrade : C");
else if((avg>=33)&&(avg<=40)
printf("\nGrade : D");
else
printf("\nGrade : Fail");
getch();
}
@programming_and_coding
14. Program to print numbers from 1 to n using while loop.
#include<stdio.h>
#include<conio.h>
void main()
{
int i=1, n;
clrscr();
printf("Enter n : ");
scanf("%d", &n);
while(i<=n)
{
printf("%d\t",i);
i++;
}
getch();
}
@programming_and_coding
#include<stdio.h>
#include<conio.h>
void main()
{
int i=1, n;
clrscr();
printf("Enter n : ");
scanf("%d", &n);
while(i<=n)
{
printf("%d\t",i);
i++;
}
getch();
}
@programming_and_coding
15. Program to print numbers from n to 1 using Do While loop.
#include<stdio.h>
#include<conio.h>
void main()
{
int i=1, n;
clrscr();
printf("Enter n : ");
scanf("%d", &n);
i=n;
do
{
printf("%d\t",i);
i--;
} while (i >= 1);
getch();
}
@programming_and_coding
#include<stdio.h>
#include<conio.h>
void main()
{
int i=1, n;
clrscr();
printf("Enter n : ");
scanf("%d", &n);
i=n;
do
{
printf("%d\t",i);
i--;
} while (i >= 1);
getch();
}
@programming_and_coding
16. Program to print first n even numbers.
#include<stdio.h>
#include<conio.h>
void main()
{
int i = 2, n;
//to print odd numbers set variable i = 1
clrscr();
printf("Enter n : ");
scanf("%d", &n);
while(i<=n)
{
printf("%d\t", i);
i = i + 2;
}
getch();
}
16. Program to print first n even numbers.
#include<stdio.h>
#include<conio.h>
void main()
{
int i = 2, n;
//to print odd numbers set variable i = 1
clrscr();
printf("Enter n : ");
scanf("%d", &n);
while(i<=n)
{
printf("%d\t", i);
i = i + 2;
}
getch();
}
@programming_and_coding
#include<stdio.h>
#include<conio.h>
void main()
{
int i = 2, n;
//to print odd numbers set variable i = 1
clrscr();
printf("Enter n : ");
scanf("%d", &n);
while(i<=n)
{
printf("%d\t", i);
i = i + 2;
}
getch();
}
16. Program to print first n even numbers.
#include<stdio.h>
#include<conio.h>
void main()
{
int i = 2, n;
//to print odd numbers set variable i = 1
clrscr();
printf("Enter n : ");
scanf("%d", &n);
while(i<=n)
{
printf("%d\t", i);
i = i + 2;
}
getch();
}
@programming_and_coding
17. Program to accept a number and print that number in reverse order.
Ex:- 1024
Output:- 4201
#include<stdio.h>
#include<conio.h>
void main()
{
int reminder, n;
clrscr();
printf("Enter n : ");
scanf("%d", &n);
while(n>0)
{
reminder=n%10;
printf("%d", reminder);
n=n/10;
}
getch();
}
@programming_and_coding
Ex:- 1024
Output:- 4201
#include<stdio.h>
#include<conio.h>
void main()
{
int reminder, n;
clrscr();
printf("Enter n : ");
scanf("%d", &n);
while(n>0)
{
reminder=n%10;
printf("%d", reminder);
n=n/10;
}
getch();
}
@programming_and_coding
18. Program to accept a number and print sum of it’s digits.
#include<stdio.h>
#include<conio.h>
void main()
{
int reminder, sum=0, n;
clrscr();
printf("Enter n : ");
scanf("%d", &n);
while(n>0)
{
reminder = n % 10;
sum = sum + reminder;
n = n / 10;
}
printf("Sum of digits : %d",sum);
getch();
}
@programming_and_coding
#include<stdio.h>
#include<conio.h>
void main()
{
int reminder, sum=0, n;
clrscr();
printf("Enter n : ");
scanf("%d", &n);
while(n>0)
{
reminder = n % 10;
sum = sum + reminder;
n = n / 10;
}
printf("Sum of digits : %d",sum);
getch();
}
@programming_and_coding
19. Program to take a number from user and check whether it is Armstrong number or not.
#include<stdio.h>
#include<conio.h>
void main()
{
int i=2, temp, rem, sum=0, n;
clrscr();
printf("Enter n : ");
scanf("%d", &n);
temp = n;
while(n>0)
{
rem = n%10;
sum = sum+(rem*rem*rem);
n = n/10;
}
if(temp == sum)
printf("Entered number is an Armstrong Number");
else
printf("Entered number is not an Armstrong Number");
getch();
}
@programming_and_coding
#include<stdio.h>
#include<conio.h>
void main()
{
int i=2, temp, rem, sum=0, n;
clrscr();
printf("Enter n : ");
scanf("%d", &n);
temp = n;
while(n>0)
{
rem = n%10;
sum = sum+(rem*rem*rem);
n = n/10;
}
if(temp == sum)
printf("Entered number is an Armstrong Number");
else
printf("Entered number is not an Armstrong Number");
getch();
}
@programming_and_coding
19. Program to take a number from user and check whether it is Armstrong number or not.
#include<stdio.h>
#include<conio.h>
void main()
{
int i=2, temp, rem, sum=0, n;
clrscr();
printf("Enter n : ");
scanf("%d", &n);
temp = n;
while(n>0)
{
rem = n%10;
sum = sum+(rem*rem*rem);
n = n/10;
}
if(temp == sum)
printf("Entered number is an Armstrong Number");
else
printf("Entered number is not an Armstrong Number");
getch();
}
@programming_and_coding
#include<stdio.h>
#include<conio.h>
void main()
{
int i=2, temp, rem, sum=0, n;
clrscr();
printf("Enter n : ");
scanf("%d", &n);
temp = n;
while(n>0)
{
rem = n%10;
sum = sum+(rem*rem*rem);
n = n/10;
}
if(temp == sum)
printf("Entered number is an Armstrong Number");
else
printf("Entered number is not an Armstrong Number");
getch();
}
@programming_and_coding
20. Program to take number from user and print table of that number.
#include<stdio.h>
#include<conio.h>
void main()
{
int i, n;
clrscr();
printf("Enter number : ");
scanf("%d", &n);
for(i = 1; i <= 10; i++)
printf("%d × %d = %d\n", n, i, n*i);
getch();
}
@programming_and_coding
#include<stdio.h>
#include<conio.h>
void main()
{
int i, n;
clrscr();
printf("Enter number : ");
scanf("%d", &n);
for(i = 1; i <= 10; i++)
printf("%d × %d = %d\n", n, i, n*i);
getch();
}
@programming_and_coding
21. Pattern 1
•
• •
• • •
• • • •
• • • • •
#include<stdio.h>
#include<conio.h>
void main()
{
int i, j, n;
clrscr();
printf("Enter number :");
scanf("%d", &n);
for(i=1; i<=n; i++)
{
for(j=1; j<=i; j++)
{
printf("• ");
}
printf("\n");
}
getch();
}
@programming_and_coding
•
• •
• • •
• • • •
• • • • •
#include<stdio.h>
#include<conio.h>
void main()
{
int i, j, n;
clrscr();
printf("Enter number :");
scanf("%d", &n);
for(i=1; i<=n; i++)
{
for(j=1; j<=i; j++)
{
printf("• ");
}
printf("\n");
}
getch();
}
@programming_and_coding
22. Pattern 2
• • • • •
• • • •
• • •
• •
•
#include<stdio.h>
#include<conio.h>
void main()
{
int i, j, n;
clrscr();
printf("Enter number : ");
scanf("%d", &n);
for(i=n; i>=1; i--)
{
for(j=1;j<=i;j++)
{
printf("• ");
}
printf("\n");
}
getch();
}
@programming_and_coding
• • • • •
• • • •
• • •
• •
•
#include<stdio.h>
#include<conio.h>
void main()
{
int i, j, n;
clrscr();
printf("Enter number : ");
scanf("%d", &n);
for(i=n; i>=1; i--)
{
for(j=1;j<=i;j++)
{
printf("• ");
}
printf("\n");
}
getch();
}
@programming_and_coding
23. Pattern 3
•
• •
• • •
• • • •
• • • • •
#include<stdio.h>
#include<conio.h>
void main()
{
char ch = '*';
int n,i, j, no_of_spaces = 0, spaceCount;
printf("Enter number : ");
scanf("%d", &n);
printf("\n");
no_of_spaces = n - 1;
for (i = 1; i <= n; i++)
{
for (spaceCount = no_of_spaces; spaceCount >= 1; spaceCount--)
{
printf(" ");
}
for (j = 1; j <= i; j++)
{
printf("%2c", ch);
}
printf("\n");
no_of_spaces--;
}
getch();
}
#pattern
@programming_and_coding
•
• •
• • •
• • • •
• • • • •
#include<stdio.h>
#include<conio.h>
void main()
{
char ch = '*';
int n,i, j, no_of_spaces = 0, spaceCount;
printf("Enter number : ");
scanf("%d", &n);
printf("\n");
no_of_spaces = n - 1;
for (i = 1; i <= n; i++)
{
for (spaceCount = no_of_spaces; spaceCount >= 1; spaceCount--)
{
printf(" ");
}
for (j = 1; j <= i; j++)
{
printf("%2c", ch);
}
printf("\n");
no_of_spaces--;
}
getch();
}
#pattern
@programming_and_coding
24. Pattern 4
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
#include<stdio.h>
#include<conio.h>
void main()
{
int n, i, j;
printf("Enter number : ");
scanf("%d", &n);
for (i = 1; i <= n; i++)
{
for (j = 1; j <= i; j++)
{
printf("%d ", j);
}
printf("\n");
}
getch();
}
#pattern
@programming_and_coding
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
#include<stdio.h>
#include<conio.h>
void main()
{
int n, i, j;
printf("Enter number : ");
scanf("%d", &n);
for (i = 1; i <= n; i++)
{
for (j = 1; j <= i; j++)
{
printf("%d ", j);
}
printf("\n");
}
getch();
}
#pattern
@programming_and_coding
25. Pattern 5
1
2 1
3 2 1
4 3 2 1
5 4 3 2 1
#include <stdio.h>
#include<conio.h>
void main()
{
int i, j, n;
printf("Enter number : ");
scanf("%d", &n);
printf("\n");
for (i = 1; i <= n; i++)
{
for (j = i; j >= 1; j--)
{
printf("%d ", j);
}
printf("\n");
}
getch();
}
#patternn
@programming_and_coding
1
2 1
3 2 1
4 3 2 1
5 4 3 2 1
#include <stdio.h>
#include<conio.h>
void main()
{
int i, j, n;
printf("Enter number : ");
scanf("%d", &n);
printf("\n");
for (i = 1; i <= n; i++)
{
for (j = i; j >= 1; j--)
{
printf("%d ", j);
}
printf("\n");
}
getch();
}
#patternn
@programming_and_coding
Hello guyzz,🙏
Want to learn coding?
If your basic concept is strong then you can easily switch to any programming language efficiently.
This awesome channel on telegram will serve you C language program from basic to advance in a serial order that help you in crack any examination in effective way .
Check out this incomparable channel on telegram for all update and subscribe them to understand the concept of C language nd get a job in top MNC.
@programming_and_coding
@programming_and_coding
@programming_and_coding
@programming_and_coding
@programming_and_coding
Dear subscriber copy &paste this message to all group nd your friendlist to help them also.
Ad:- 1
C_Language_Coding
This channel will serve you C language program from basic to advance in a serial order that help you in understand the basic and crack any IT examination in easy way .
Invite other to Subscribe this channel on telegram
@Programming_and_Coding
https://t.me/programming_and_coding
Want to learn coding?
If your basic concept is strong then you can easily switch to any programming language efficiently.
This awesome channel on telegram will serve you C language program from basic to advance in a serial order that help you in crack any examination in effective way .
Check out this incomparable channel on telegram for all update and subscribe them to understand the concept of C language nd get a job in top MNC.
@programming_and_coding
@programming_and_coding
@programming_and_coding
@programming_and_coding
@programming_and_coding
Dear subscriber copy &paste this message to all group nd your friendlist to help them also.
Ad:- 1
C_Language_Coding
This channel will serve you C language program from basic to advance in a serial order that help you in understand the basic and crack any IT examination in easy way .
Invite other to Subscribe this channel on telegram
@Programming_and_Coding
https://t.me/programming_and_coding
Telegram
C_Language_Coding
This channel will serve you C language program from basic to advance in a serial order that help you in understand the basic and crack any IT examination in easy way .
Invite other to Subscribe this channel on telegram
@Programming_and_Coding
Invite other to Subscribe this channel on telegram
@Programming_and_Coding
GOOGLE Hiring Application Engineering Intern, Summer 2021
Last Date: 8 Dec 2020
Click Here to Apply👇
https://careers.google.com/jobs/results/89086682550149830-application-engineering-intern-summer-2021/
@programming_and_coding
#Update 1
Last Date: 8 Dec 2020
Click Here to Apply👇
https://careers.google.com/jobs/results/89086682550149830-application-engineering-intern-summer-2021/
@programming_and_coding
#Update 1
26. Pattern 6
A
B C
D E F
G H I J
K L M N O
#include<stdio.h>
#include<conio.h>
void main()
{
int i, j, n;
clrscr();
printf("Enter number : ");
scanf("%d", &n);
int c = 'A';
for (i = 0; i < n; i++)
{
for (j = 0; j <= i; j++)
{
printf("%c", c);
c = c + 1;
}
printf("\n");
}
getch();
}
#pattern
@programming_and_coding
A
B C
D E F
G H I J
K L M N O
#include<stdio.h>
#include<conio.h>
void main()
{
int i, j, n;
clrscr();
printf("Enter number : ");
scanf("%d", &n);
int c = 'A';
for (i = 0; i < n; i++)
{
for (j = 0; j <= i; j++)
{
printf("%c", c);
c = c + 1;
}
printf("\n");
}
getch();
}
#pattern
@programming_and_coding
27. Pattern 7
1
1 2 1
1 2 3 2 1
1 2 3 4 3 2 1
1 2 3 4 5 4 3 2 1
#include<stdio.h>
#include<conio.h>
void main()
{
int i, j, n;
clrscr();
printf("Enter number : ");
scanf("%d", &n);
for (i = 1; i <= n; i++)
{
for (j = 1; j <= i; j++)
{
printf("%d", j);
}
for (j = i - 1; j >= 1; j--)
{
printf("%d", j);
}
printf("\n");
}
getch();
}
#pattern
@programming_and_coding
1
1 2 1
1 2 3 2 1
1 2 3 4 3 2 1
1 2 3 4 5 4 3 2 1
#include<stdio.h>
#include<conio.h>
void main()
{
int i, j, n;
clrscr();
printf("Enter number : ");
scanf("%d", &n);
for (i = 1; i <= n; i++)
{
for (j = 1; j <= i; j++)
{
printf("%d", j);
}
for (j = i - 1; j >= 1; j--)
{
printf("%d", j);
}
printf("\n");
}
getch();
}
#pattern
@programming_and_coding
28. Pattern 8 (Binary Pattern)
1
0 1
1 0 1
0 1 0 1
1 0 1 0 1
#include<stdio.h>
#include<conio.h>
void main()
{
int i, j;
int count = 1;
clrscr();
for (i = 1; i <= 5; i++)
{
for (j = 1; j <= i; j++)
{
printf("%d", count++ % 2);
if (j == i && i != 5)
printf("\n");
}
if (i % 2 == 0)
count = 1;
else
count = 0;
}
getch();
}
#pattern
@programming_and_coding
1
0 1
1 0 1
0 1 0 1
1 0 1 0 1
#include<stdio.h>
#include<conio.h>
void main()
{
int i, j;
int count = 1;
clrscr();
for (i = 1; i <= 5; i++)
{
for (j = 1; j <= i; j++)
{
printf("%d", count++ % 2);
if (j == i && i != 5)
printf("\n");
}
if (i % 2 == 0)
count = 1;
else
count = 0;
}
getch();
}
#pattern
@programming_and_coding
29. Pattern 9
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
#include<stdio.h>
#include<conio.h>
void main()
{
int i, j, k, l, n;
clrscr();
printf("Enter number : ");
scanf("%d", &n);
printf("\n");
for (i = n; i >= 1; i--)
{
for (j = 1; j <= i; j++)
printf("%d", j);
printf("\n");
}
getch();
}
@programming_and_coding
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
#include<stdio.h>
#include<conio.h>
void main()
{
int i, j, k, l, n;
clrscr();
printf("Enter number : ");
scanf("%d", &n);
printf("\n");
for (i = n; i >= 1; i--)
{
for (j = 1; j <= i; j++)
printf("%d", j);
printf("\n");
}
getch();
}
@programming_and_coding