Input Specification: The first line contains the size N1 of the first array. Next line give the contents of the first array. Next line contains the size N2 of the second array. Next line give the contents of the second array.Output Format: Output must be a single number which is the smallest number occurring in the first array that does not occur in the second. In case there is no such number, output NO.#include<stdio.h> # define MAX_SIZE 20 int main(){ int a[MAX_SIZE], b[MAX_SIZE],comn[MAX_SIZE]; int na,nb,count=0,g=0; scanf("%d",&na); if(na>0) { for(int i=0;i<na;i++) { scanf("%d ",&a[i]); } scanf("%d",&nb); for(int j=0;j<nb;j++) { scanf("%d ",&b[j]); } for(int k=0;k<na;k++){ for(int l=0;l<nb;l++) { if(a[k]==b[l]) { count++; } } if(count==0) { comn[g]=a[k]; g+=1; } if(count>=1) { ; } count=0; } int smallest=comn[0]; for(int j=0;j<g;j++) { if (comn[j]<smallest) { smallest = comn[j]; } } if(g!=0) { printf("%d", smallest); } else { printf("NO"); } } else { printf("NO"); } return 0; }ThanksHappy Computing !
Sunday, February 25, 2018
C program : Given two arrays of integers output the smallest number in the first array not present in the second one.
Subscribe to:
Post Comments (Atom)
What is a superconductor?
A superconductor is a material that can conduct electricity with zero electrical resistance when it is cooled below a specific, very cold t...
-
Assuming you are working with a newly returned ResultSet whose cursor is pointing before the first row, an easier way to check this is to...
-
Acronym Full Form AJAX Asynchronous JavaScript and XML API Application Programming Interface APK Android Application Package ASP Activ...
-
Here are some links to online work sites https://www.upwork.com/ https://www.guru.com/ https://studio.envato.com/freelance-switch/ htt...
got it.. Thank you soo much
ReplyDelete