answersLogoWhite

0

What else can I help you with?

Related Questions

C program to find whether the given number is prime or not?

int is_prime(int n){ int flag=1; if(n==1) return 0; int root=(int)sqrt(n); while(root!=1){ if(n%root==0){ flag=0; break; } root--; } return flag; }


Flowchart for linear search?

PROGRAM://LINEAR SEARCH USING FUNCTIONS#includevoid linear(int [],int,int);main(){int n,i,x,a[10];printf("\nEnter the limit:");scanf("%d",&n);printf("\nEnter the elements:");for(i=0;i


Java code to print prime numbers from 1 to 100?

import java.io.*; class prmNo { public static void main(String[] args) { Console con = System.console(); System.out.println("Enter length of list :"); int n = con.readLine(); boolean flag; System.out.print("1 "); for (int i=2;i<=n;i++) { for (int j=2;j<i;j++) { if (i%j==0) flag=true; } if(!flag) System.out.print(i+ " "); flag=false; } } }


Write a program to Print pyramid of prime numbers using loops in c?

#include #includevoid main() int prime(int num) { inti,flag; for(i=2;i


Write a c program to print mean median and mode?

#include<stdio.h> #define MAXVAL 1000 void sort1(int a[],int n); void median(int a[],int n); void mode(int a[],int n); int main() { int n; int arr[MAXVAL]; int i; printf("Enter the number of elements:"); scanf("%d",&n); printf("Enter the values:"); for(i=0;i<n;i++) { printf("a[%d]=",i); scanf("%d",&arr[i]); } sort1(arr,n); median(arr,n); mode(arr,n); } void sort1(int a[],int n) { int i; int j; int temp; for(i=0;i<n;i++) { for(j=i;j<n;j++) { if(a[i]>a[j]) { temp=a[i]; a[i]=a[j]; a[j]=temp; } } } } void median(int a[],int n) { int median; int mid; if((n%2)==0) { mid=n/2; median=(a[mid-1]+a[mid])/2; } else { mid=(n+1)/2; median=a[mid-1]; } printf("The median is:%d\n",median); } void mode(int a[],int n) { int i; int count1[MAXVAL]; for(i=0;i<n;i++) { count1[i]=0; } for(i=0;i<n;i++) { count1[a[i]]++; } i--; int mode=count1[0]; int j; int k; int flag=0; for(j=0;j<=a[i];j++) { if(count1[j]>count1[mode]) mode=j; } for(j=0;j<=a[i];j++) { for(k=j+1;k<=a[i];k++) { if(count1[j]=count1[k] && count1[j]>count1[mode]) { flag=1; } } } if(flag==1) { printf("Mode cannot be calculated"); } else printf("the Mode is:%d",mode); }


Prime number program in C using recursion?

//Program to check number is prime or not using recursive function #include<stdio.h> #include<stdlib.h> void prime(int num,int count) { if(count<num) { if(num%count==0) { printf("%d is not Prime Number\n",num); goto exit; } count += 1; if(count<num) { prime(num,count); } } if(num==count) { printf("%d is a Prime Number\n",num); } exit: return 0; } int main() { system("cls"); int gvar; printf("Enter the number = "); scanf("%d",&gvar); prime(gvar,2); printf("\nashokakhil@gmail.com\n"); system("PAUSE"); return 0; } I think this can be another solution #include<stdio.h> #include<conio.h> int prime(int); main() { int i=1,r; clrscr(); r=prime(i); if(r==1) printf("\n\n\tNo is prime "); getch(); } int prime(int i) { int n=1,ans,flag=1; i++; ans=n%i; if(ans==0) { printf("\t\t\n\nNo is not prime"); flag=0; return flag; } if((i!=n-1)&&(n!=1)) flag=prime(i); return flag; }


Java source code to find prime number?

/* Program to Find whether number is Prime or Not. */ class PrimeNo{ public static void main(String args[]){ int num = Integer.parseInt(br.readLine()); int flag=0; for(int i=2;i


What is the use of direction flag and Trace flag in 8086?

The direction flag (DF) controls the direction of repeated string instructions. The trap flag (TF) executes one instruction and then executes a debug (INT 1) instruction so that a debugger can single step through a program.


Write a program to compare two strings with out using strcmp function?

#include main() { //please read two strings int str1 and str2// while(str1[i]!='/0' &&str2[i]!='/0') if(str1[i]!=str2[i]) flag=1; if(flag==1) printf("equal"); } #include main() { //please read two strings int str1 and str2// while(str1[i]!='/0' &&str2[i]!='/0') if(str1[i]!=str2[i]) flag=1; if(flag==1) printf("equal"); }


To compare two strings using pointers and arrays?

#includevoid main(){char str1[10],str2[10];int i=0;int flag = 0;printf("enter first string\n");scanf("%s",str1);printf("enter second string\n");scanf("%s",str2);while(str1[i]!='/0' && str2[i]!='/0'){if(str1[i]!=str2[i])flag=1;if(flag==1){printf("not equal\n");break;}if (flag==0){printf("equal\n");break;}}}


30 examples of variables?

int n1; int n2; int n3; int n4; int n5; int n6; int n7; int n8; int n9; int n10; int n11; int n12; int n13; int n14; int n15; int n16; int n17; int n18; int n19; int n20; int n21; int n22; int n23; int n24; int n25; int n26; int n27; int n28; int n29; int n30;


Why is the American flag waving on the moon?

the flag waves because it was planted in the soil and Neil Armstrong twisted the poles.this is obvious because int other footage you can see the flag is not moving when he walks past it.Since there is no wind on the moon the flag pole made of the moon landing was an upside-down "L" shape to hold the flag material straight out.