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
Channel created
Interview Hacks πŸ‘ˆ

No matter how poorly a candidate is doing.There is always something they got right. Find a way to infuse some positivity into the interview.
1. Program to print "Hello World!!".

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

void main()
{
clrscr();
printf("Hello World!!");
getch();
}
#basics
@programming_and_coding
2. Program to assign values of two numbers and print their addition.

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

void main()
{
int a=10,b=20;
clrscr();

int ans = a + b;

printf("Addition is : %d",ans);

getch();
}
#basics
@programming_and_coding
3. Program to accept values of two numbers and print their addition.

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

void main()
{
int a,b,ans;
clrscr();

printf("Enter 1st number:");
scanf("%d",&a);

printf("Enter 2nd number:");
scanf("%d",&b);

ans = a + b;

printf("Addition is : %d",ans);

getch();
}
#basics
@programming_and_coding
4. Program to print simple interest.

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

void main()
{
float interest, p, r, n;
clrscr();

printf("Enter value of P: ");
scanf("%f",&p);

printf("Enter value of R: ");
scanf("%f",&r);

printf("Enter value of N: ");
scanf("%f",&n);

interest=p*r*n/100f;

printf("Simple Interest : %f", interest);

getch();
}
#basics
@programming_and_coding
5. Program to accept value of radius and print area of a circle.

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

void main()
{
float area,radius;
clrscr();

printf("Enter Radius:");
scanf("%f",&radius);

area=3.14*radius*radius;

printf("Area : %6.2f",area);

getch();
}
#basics
@programming_and_coding
6. Program to accept a number from user and print it’s square & cube.

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

void main()
{
int n,sqre,cube;
clrscr();

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

sqre=n*n;
cube=n*n*n;

printf("\nSquare: %d\nCube: %d",sqre,cube);

getch();
}
#basics
@programming_and_coding
7. Program to accept two values of a & b and swap their values.

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

void main()
{
int a,b,temp;
clrscr();

printf("Enter 1st number : ");
scanf("%d",&a);

printf("Enter 2nd number : ");
scanf("%d",&b);

printf("\nBefore Swapping...");
printf("A=%d, B=%d",a,b);

temp=a;
a=b;
b=temp;

printf("\nAfter Swapping...");
printf("\n A=%d, B=%d",a,b);

getch();
}
#basics
@programming_and_coding
8. Program to accept two number and print largest among them.

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

void main()
{
int a,b;
clrscr();

printf("Enter 1st number : ");
scanf("%d",&a);

printf("Enter 2nd number : ");
scanf("%d",&b);

if(a>b)
printf("Largest value is : %d",a);
else
printf("Largest value is : %d",b);

getch();
}
#if_else
@programming_and_coding
9. Program to accept a number and check whether the number is Positive, Negative or Zero.

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

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

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

if(n>0)
printf("Number is positive");
else if(n<0)
printf("Number is negative");
else
printf("Number is Zero");

getch();
}
#if_else
@programming_and_coding
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