Skip to content

Instantly share code, notes, and snippets.

@btechmag
btechmag / add.c
Created April 9, 2021 11:22
Program to add two numbers
#include<stdio.h>
main()
{
int a,b,sum;
a=2,b=3;
sum=a+b;
printf("the sum of a&b is%d\n",sum);
return 0;
}
@btechmag
btechmag / reverse_characters.c
Last active April 15, 2021 10:34
Simple C program to reverse the given characters.
#include<stdio.h>
main()
{
char char1='X';
char char2='M';
char char3='L';
printf("\n the reverse of %c%c%c is %c%c%c\n", char1,char2,char3,char3,char2,char1);
getch();
return 0;
}
@btechmag
btechmag / sum.c
Created April 15, 2021 10:59
Simple C program to add two numbers
#include<stdio.h>
main()
{
printf("Addition of 6 and 9 is %d", 6 + 9);
return 0;
}
@btechmag
btechmag / #F.c
Created April 15, 2021 11:07
C program to display 'F 'using (#). also display a big 'C'.
#include<stdio.h>
main()
{
printf("\n\n\n######\n");
printf("#\n");
printf("#\n");
printf("#####\n");
printf("#\n");
printf("#\n");
printf("#\n");
@btechmag
btechmag / calc.c
Created April 15, 2021 11:10
Simple calculator program for beginners
#include<stdio.h>
int main(int argc, char const *argv[])
{
/* c program to implement calculater fetures*/
int a,b,add,sub,mul,div;
a=2,b=2;
printf("calculater fetures:\n");
add=a+b;
sub=a-b;
mul=a*b;
@btechmag
btechmag / multiplication.c
Last active April 15, 2021 11:18
Simple C program to compute multiplication table for a given number
#include<stdio.h>
int main(int argc, char const *argv[])
{ /* sud1*/
int i,n;
n=9;
printf("\enter the num\n");
scanf("%d",&n);
for(i=1;i<=10;i++)
{
printf("\n%d*%d=%d",n,i,n*i);
@btechmag
btechmag / convert days week month.c
Created April 15, 2021 12:06
C program to convert specified days into years , weeks and days.
#include<stdio.h>
int main()
{
int days,weeks,years;
days=1329;
years=(days/365);
printf("\n years:%d \n",years);
weeks=(days%365)/7;
printf("\n weeks:%d \n",weeks);
days=days-((years365)+(weeks7));
@btechmag
btechmag / triangle.c
Last active April 15, 2021 14:30
C Program that reads three values from keyboard and checks whether it is possible to make a triangle with them and also calculate the perimeter.
#include<stdio.h>
int main()
{
float x,y,z,perimeter;
printf("enter the values of x, y, z:");
scanf("%f %f %f",&x, &y, &z);
if(x < (y + z) && y < (x + z) && z < (x + y))
{
perimeter = x + y + z;
printf("The perimeter of triangle = %f\n",perimeter);
@btechmag
btechmag / multiply.c
Created April 15, 2021 14:39
C Program to read two integers and checks whether they can be multiplied or not.
#include<stdio.h>
int main()
{
int a, b;
printf("The values of a and b are:");
scanf("%d %d", &a, &b);
if(a % b == 0)
{
printf("Multiplied");
}
@btechmag
btechmag / left_shift.c
Created April 15, 2021 14:55
Program to read an integer from the keyboard and left shift the integer by two bits.
#include<stdio.h>
int main()
{
int x;
printf("Read the integer from keyboard: ");
scanf("%d", &x);
printf("Integer value = %d", x);
x <<= 2;
printf("The left shifted data is %d", x);
return 0;