Answers for "c programming writing code"

C
0

example c programming language

#include<stdio.h>
#include<conio.h>
void main()
{
	char choise;

	char hel;

	int p,k,g;

	int b,c,e;

	printf("n Welcome to GM Program :) nn It's a one time usalbe program so you can start the program again and again");
	printf("nn Type 't' for Tables");
	printf("nn Type 'h' for ASMD is Add,Sub,Mul,Div");
	printf("nn Enter :- ");
	scanf("%c",&choise);

	switch(choise)
	{
		case 't':
		printf("nn Enter a number to make the table :- ");
		scanf("%d",&p);
		for(k=1;k<11;k++)
		{
			g=p*k;
			printf("nn %dx%d=%d",p,k,g);
		}
		break;
		case 'h':
		printf("nn Type 'a' for add nn Type 's' for sub nn Type 'm' for mul nn Type 'd' for div");
		printf("nn Enter :- ");
		scanf("%s",&hel);
		switch(hel)
		{
			case 'a':
			printf("nn Enter two number to add :- ");
			scanf("%d%d",&b,&c);
			e=b+c;
			printf("nn Your answer :- %d+%d=%d",b,c,e);
			break;
			case 's':
			printf("nn Enter two number to sub :- ");
			scanf("%d%d",&b,&c);
			e=b-c;
			printf("nn Your answer :- %d-%d=%d",b,c,e);
			break;
			case 'm':
			printf("nn Enter two number to mul :- ");
			scanf("%d%d",&b,&c);
			e=b*c;
			printf("nn Your answer :- %dx%d=%d",b,c,e);
			break;
			case 'd':
			printf("nn Enter two number to div :- ");
			scanf("%d%d",&b,&c);
			e=b/c;
			printf("nn Your answer :- %d/%d=%d",b,c,e);
			break;
	   }
	}
	getch();
	return 0;
}
/* program with switch and loop */
Posted by: Guest on December-22-2021
0

c programming programiz

#include <stdio.h>
int main() {

  int i, n;

  // initialize first and second terms
  int t1 = 0, t2 = 1;

  // initialize the next term (3rd term)
  int nextTerm = t1 + t2;

  // get no. of terms from user
  printf("Enter the number of terms: ");
  scanf("%d", &n);

  // print the first two terms t1 and t2
  printf("Fibonacci Series: %d, %d, ", t1, t2);

  // print 3rd to nth terms
  for (i = 3; i <= n; ++i) {
    printf("%d, ", nextTerm);
    t1 = t2;
    t2 = nextTerm;
    nextTerm = t1 + t2;
  }

  return 0;
}
Posted by: Guest on January-06-2022

Code answers related to "C"

Browse Popular Code Answers by Language