C_Language_Coding
1.33K subscribers
4 files
31 links
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
Download Telegram
10. Program to check whether the number is even or odd.

#include<stdio.h>
#include<conio.h>

void main()
{
int n;
clrscr();

printf("Enter number: );
scanf("%d",&n);

if(n%2==0)
printf("Number is even");
else
printf("Number is odd");

getch();
}
#if_else
@programming_and_coding
11. Program to accept three numbers from user and print them in ascending and decending order.

#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
clrscr();
printf("Enter numbers:");
scanf("%d %d %d",&a,&b,&c);

if((a>=b)&&(a>=c))
{
if(b>=c)
{
printf("\nDescending : %d %d %d",a,b,c);
printf("\nAscending : %d %d %d",c,b,a);
}
else
{
printf("\nDescending : %d %d %d",a,c,b);
printf("\nAscending : %d %d %d",b,c,a);
}
}
else if((b>=a)&&(b>=c))
{
if(a>=c)
{
printf("\nDescending : %d %d %d",b,a,c);
}
}
else
{
if(b>=a)
{
printf("\nDescending : %d %d %d",c,b,a);
printf("\nAscending : %d %d %d",a,b,c);
}
else
{
printf("\nDescending : %d %d %d",c,a,b);
printf("\nAscending : %d %d %d",b,a,c);
}
}
getch();
}
#if_else
@programming_and_coding
12. Program to find the roots of a quadratic equation.

#include<stdio.h>
#include<conio.h>
#include<math.h>

void main()
{
float a, b, c, discriminant, real;
double r1, r2, imag;

printf("Enter coefficients a, b and c: ");
scanf("%f%f%f", &a, &b, &c);

discriminant = b * b - 4 * a * c;
if (discriminant > 0)
{
r1 = (-b + sqrt(discriminant)) / (2 * a);
r2 = (-b - sqrt(discriminant)) / (2 * a);
printf("Roots are: %.2f and %.2f", r1, r2);
}
else if (discriminant == 0)
{
r1 = r2 = -b / (2 * a);
printf("Roots are: %.2f and %.2f", r1, r2)
}
else
{
real = -b / (2 * a);
imag = sqrt(-discriminant) / (2 * a);
printf("Roots : %.2f+%.2fi and %.2f-%.2fi", real, imag, real, imag);
}
getch();
}

@programming_and_coding
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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