Please Follow below \'C\' Programming programs set guidelines and write program
ID: 3802952 • Letter: P
Question
Please Follow below 'C' Programming programs set guidelines and write program set below as documented in the detailed instructions below. Thank you so much
****All programs must be written using the VC++ 2015 compiler****
*****PLEASE DOUBLE CHECK TO MAKE SURE PROGRAM COMPILES AND DOES NOT SUFFER RUNTIME ERROR*******
A) Required Items/Software:
Visual C++ 2015 (Visual Studio 2015 Professional or Visual Studio Express 2015)
Capture the output from at least two different test cases (actual output) and either submit a text file or a screen shot of the output in a .doc file.
Textbook: PROGRAMMING IN C, 4th Edition Stephen G Kochan.
Program Documentation Guidelines
• All coding submitted must follow the coding standards found in the textbook and the modifications as specified below. The PROGRAMMING IN C, 4th Edition Stephen G Kochan follows standard C programming coding guidelines and practices good habits learned in beginning programming.
• Every C program should have a leading comment block that identifies the author, course, program number, and any references used.
All programs/projects must have leading comment header that looks similar to below:
// Author: James Bond
// Course: COSC 1420
// Program 2
// References:
• If code is borrowed from other sources- cite it in comments (references). In programming one does not always have to "reinvent the wheel" each time you program. One should however, understand the code and give credit where it is found.
• In a Visual C++ console program, if the output window closes quickly add the following statement as the last statement in the main() function:
cin.get(); //Hold the output window
• When creating your project in VC++ make sure you select an empty project. Otherwise, the IDE will add additional code that will likely not let your program compile.
• Do not include the following directive:
#include "stdafx.h"
This will cause the program to not compile when grading. See previous bullet. • In Visual C++, to use scanf()/printf() properly add the following directive before the #include statement (top of the program, first line):
#define _CRT_SECURE_NO_WARNINGS //add this line #include
• Enter file name from the keyboard:
FILE *fp; char file[MAX];
printf("Enter the name of the file to be opened: ");
scanf("%s", file);
if ((fp = fopen(file, "r")) == NULL) {
fprintf(stderr,"Can't open %s file. ", file); exit(1); }
PROGRAM QUESTION
5. Karnaugh is a poor farmer who has a very small field. He wants to reclaim wasteland in the kingdom o get a new field. But the king who loves regular shape made a rule that a settler can only get a rectangular land as his field. Thus, Karnaugh should get the largest rectangular land suitable for reclamation. In the examples below the largest rectangles are (shaded) 1 0 0 In the first example, there are 2 size 4 1 1 1 0 1 1 1 0 1 0 1 1 1 rectangles. In the second example, there is 1 1 0 1 0 1 1 1 0 0 1 1 0 size 4 rectangle. In the final example, there 0 1 1 1 0 0 0 1 0 are 4 size 4 rectangles. 0 1 1 0 0 The maps of the wastelands above are grids, where'1' represents a place suitable for reclamation and '0' represents a sandy place. Write a C program to find the largest rectangle consisting only of 1's in the map, and report the size of the rectangle. Let the user enter the size and values of the matrix up to size 6. The size of a rectangle is defined by the number of 1's in it. Note that there may be two or more largest rectangles of the same size, and values may "wrap around" or overlap to determine the size Finally, ask the user if he/she wishes to run the program again. Use a constant and error check. Refer to the sample output below Sample Run Enter the size of square 21): 5 Enter the grid: 0 1 0 1 1 0 1 0 1 0 0 0 1 0 0 0 0 1 1 0 1 0 1 0 0 The largest size rectangle is 3 Run Again (Y/N) N Name the program: LargestRectanglesXX.c, where XX are your initials.Explanation / Answer
#include<stdio.h>
#include<conio.h>
void fundamental()
{
int i,j,a[4],m[4]={0,0,0,0},n,c=0,d,k[8]={0,0,0,0,0,0,0,0},e,f=0,g,l[8]={0,0,0,0,0,0,0,0},
y[13]={0,0,0,0,0,0,0,0,0,0,0,0,0},o[16]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
p[16]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},b=0,h[64];
int s,t,u,v,q,z;
clrscr();
for(i=0;i<64;i++)
{
h[i]=0;
}
printf("how numerous variable kmap you need to illuminate (2,3,4):");
scanf("%d",&d);
if(d==2)
{
printf("enter what number of minterms you need to enter:");
scanf("%d",&n);
if(n>4)
{
printf("you have entered wrong minterms on the grounds that greatest minterm in 2 variable k-guide is 4:");
goto l;
}
z:
for(i=0;i<n;i++)
{
printf("%d""th minterm:",i);
scanf("%d",&a[i]);
}
printf(" Entered minterms are : ");
for(i=0;i<=3;i++)
{
printf("%d",a[i]);
}
printf(" if emtered minterms are right press 1 or press 0 to go back:");
scanf("%d",&q);
if(q==0)
{
goto z;
}
if(q==1)
{
printf(" The grid is");
for(i=0;i<=3;i++)
{
for(j=0;j<=3;j++)
{
if(a[i]-j==0)
{
m[j]=1;
}
}
}
printf(" ");
for(i=0;i<=3;i++)
{
printf("%d",m[i]);
}
printf(" ");
printf("the ans is:");
for(i=0;i<=3;i++)
{ if(m[i]==1)
{
c++;
}
}
if(c==4)
{
printf("y=1");
}
else
{
printf("y=");
if(m[0]==1&&m[1]==1)
{
printf("!A+");
}
if(m[0]==1&&m[2]==1)
{
printf("!B+");
}
if(m[1]==1&&m[3]==1)
{
printf("B+");
}
if(m[2]==1&&m[3]==1)
{
printf("A+");
}
if(m[1]==0&&m[2]==0&&m[0]==1)
{
printf("!A!B+");
}
if(m[1]==1&&m[3]==0&&m[0]==0)
{
printf("!AB+");
}
if(m[0]==0&&m[2]==1&&m[3]==0)
{
printf("A!B+");
}
if(m[1]==0&&m[2]==0&&m[3]==1)
{
printf("AB");
}
}
getch();
}
}
if(d==3)
{
printf("enter what number of minterms you need to enter:");
scanf("%d",&e);
if(e>8)
{
printf("you have entered wrong minterms on the grounds that most extreme minterm in 3 variable is 8:");
goto l;
}
t:
for(i=0;i<e;i++)
{
printf("%d""th minterm:",i);
scanf("%d",&k[i]);
}
printf(" entered minterms are");
for(i=0;i<=7;i++)
{
printf("%d",k[i]);
}
printf(" if entered minterms are right press 1 or press 0 to go back:");
scanf("%d",&s);
if(s==0)
{
goto t;
}
if(s==1)
{
printf(" Final lattice");
for(i=0;i<=7;i++)
{
for(j=0;j<=7;j++)
{
if(k[i]-j==0)
{
l[j]=1;
}
}
}
printf(" ");
for(i=0;i<=7;i++)
{
printf("%d",l[i]);
}
printf(" ");
printf("the ans is:");
for(i=0;i<=7;i++)
{ if(l[i]==1)
{
f++;
}
}
if(f==8)
{
printf("x=1");
}
else
{
printf("x=");
if(l[0]==1&&l[1]==1&&l[4]==1&&l[5]==1)
{
y[0]=1;
printf("!B+");
}
if(l[2]==1&&l[3]==1&&l[6]==1&&l[7]==1)
{
y[1]=2;
printf("B+");
}
if(l[0]==1&&l[1]==1&&l[2]==1&&l[3]==1)
{
y[2]=3;
printf("!A+");
}
if(l[4]==1&&l[5]==1&&l[6]==1&&l[7]==1)
{
y[3]=4;
printf("A+");
}
if(l[0]==1&&l[2]==1&&l[4]==1&&l[6]==1)
{
y[4]=5;
printf("!C+");
}
if(l[1]==1&&l[3]==1&&l[7]==1&&l[5]==1)
{
y[5]=6;
printf("C+");
}
if(y[4]!=5&&y[0]!=1&&l[0]==1&&l[4]==1)
{
y[6]=7;
printf("!B!C+");
}
if(y[0]!=1&&l[1]==1&&l[5]==1&&y[5]!=6)
{
y[7]=8;
printf("!BC+");
}
if(y[5]!=6&&y[1]!=2&&l[3]==1&&l[7]==1)
{
y[8]=9;
printf("BC+");
}
if(y[4]!=5&&y[1]!=2&&l[2]==1&&l[6]==1)
{
y[9]=10;
printf("B!C+");
}
if(y[0]!=1&&l[0]==1&&l[1]==1&&y[2]!=3)
{
y[10]=11;
printf("!B!A+");
}
if(y[1]!=2&&l[3]==1&&l[2]==1&&y[2]!=3)
{
y[11]=12;
printf("!AB+");
}
if(y[1]!=2&&l[7]==1&&l[6]==1&&y[3]!=4)
{
y[12]=13;
printf("AB+");
}
if(y[0]!=1&&l[4]==1&&l[5]==1&&y[3]!=4)
{
y[13]=14;
printf("!BA+");
}
if(y[5]!=6&&l[3]==1&&l[1]==1&&y[2]!=3)
{
printf("!AC+");
}
if(y[5]!=6&&l[5]==1&&l[7]==1&&y[3]!=4)
{
printf("AC+");
}
if(y[2]!=3&&y[4]!=5&&l[0]==1&&l[2]==1)
{
printf("!A!C+");
}
if(y[4]!=5&&l[4]==1&&l[6]==1&&y[3]!=4)
{
printf("A!C+");
}
if(l[1]==0&&l[4]==0&&l[0]==1&&l[2]==0)
{
printf("!A!B!C+");
}
if(l[0]==0&&l[5]==0&&l[1]==1&&l[3]==0)
{
printf("!A!BC+");
}
if(l[1]==0&&l[2]==0&&l[3]==1&&l[7]==0)
{
printf("!ABC+");
}
if(l[3]==0&&l[6]==0&&l[0]==0&&l[2]==1)
{
printf("!AB!C+");
}
if(l[0]==0&&l[4]==1&&l[6]==0&&l[5]==0)
{
printf("A!B!C+");
}
if(l[1]==0&&l[4]==0&&l[5]==1&&l[7]==0)
{
printf("A!BC+");
}
if(l[3]==0&&l[5]==0&&l[6]==0&&l[7]==1)
{
printf("ABC+");
}
if(l[2]==0&&l[4]==0&&l[6]==1&&l[7]==0)
{
printf("AB!C+");
}
}
getch();
}
}
if(d==4)
{
printf("enter what number of minterms you need to enter:");
scanf("%d",&g);
if(g>16)
{
printf("you have entered wrong minterms in light of the fact that most extreme minterm in 4 variable is 16:");
goto l;
}
v:
for(i=0;i<g;i++)
{
printf("%d""th minterm:",i);
scanf("%d",&o[i]);
}
printf(" entered minterms are");
for(i=0;i<g;i++)
{
printf("%d",o[i]);
}
printf(" if minterms are right press 1 or press 0 to go back:");
scanf("%d",&u);
if(u==0)
{
goto v;
}
if(u==1)
{
printf(" Final network is:");
for(i=0;i<g;i++)
{
for(j=0;j<=15;j++)
{
if(o[i]-j==0)
{
p[j]=1;
}
}
}
printf(" ");
for(i=0;i<=15;i++)
{
printf("%d",p[i]);
}
printf(" ");
printf("the ans is:");
for(i=0;i<=15;i++)
{ if(p[i]==1)
{
b++;
}
}
if(b==16)
{
printf("x=1");
}
else
{
printf("x=");
if(p[0]==1&&p[1]==1&&p[2]==1&&p[3]==1&&p[4]==1&&p[5]==1&&p[6]==1&&p[7]==1)
{
h[0]=1;
printf("!A+");
}
if(p[8]==1&&p[9]==1&&p[10]==1&&p[11]==1&&p[12]==1&&p[13]==1&&p[14]==1&&p[15]==1)
{
h[1]=1;
printf("A+");
}
if(p[0]==1&&p[1]==1&&p[2]==1&&p[3]==1&&p[8]==1&&p[9]==1&&p[10]==1&&p[11]==1)
{
h[2]=1;
printf("!B+");
}
if(p[4]==1&&p[5]==1&&p[6]==1&&p[7]==1&&p[12]==1&&p[13]==1&&p[14]==1&&p[15]==1)
{
h[3]=1;
printf("B+");
}
if(p[0]==1&&p[1]==1&&p[4]==1&&p[5]==1&&p[12]==1&&p[13]==1&&p[8]==1&&p[9]==1)
{
h[4]=1;
printf("!C+");
}
if(p[2]==1&&p[3]==1&&p[6]==1&&p[7]==1&&p[10]==1&&p[11]==1&&p[14]==1&&p[15]==1)
{
h[5]=1;
printf("C+");
}
if(p[0]==1&&p[2]==1&&p[4]==1&&p[6]==1&&p[8]==1&&p[10]==1&&p[12]==1&&p[14]==1)
{
h[6]=1;
printf("!D+");
}
if(p[1]==1&&p[3]==1&&p[5]==1&&p[7]==1&&p[9]==1&&p[11]==1&&p[13]==1&&p[15]==1)
{
h[7]=1;
printf("D+");
}
if(p[0]==1&&p[1]==1&&p[2]==1&&p[3]==1&&h[0]!=1&&h[2]!=1)
{
h[8]=1;
printf("!A!B+");
}
if(p[4]==1&&p[5]==1&&p[6]==1&&p[7]==1&&h[0]!=1&&h[3]!=1)
{
h[9]=1;
printf("!AB+");
}
if(p[12]==1&&p[13]==1&&p[14]==1&&p[15]==1&&h[1]!=1&&h[3]!=1)
{
h[10]=1;
printf("AB+");
}
if(p[8]==1&&p[9]==1&&p[10]==1&&p[11]==1&&h[1]!=1&&h[2]!=1)
{
h[11]=1;
printf("A!B+");
}
if(p[0]==1&&p[4]==1&&p[8]==1&&p[12]==1&&h[4]!=1&&h[6]!=1)
{
h[12]=1;
printf("!C!D+");
}
if(p[1]==1&&p[5]==1&&p[9]==1&&p[13]==1&&h[4]!=1&&h[7]!=1)
{
h[13]=1;
printf("!CD+");
}
if(p[3]==1&&p[7]==1&&p[11]==1&&p[15]==1&&h[7]!=1&&h[5]!=1)
{
h[14]=1;
printf("CD+");
}
if(p[2]==1&&p[6]==1&&p[10]==1&&p[14]==1&&h[5]!=1&&h[6]!=1)
{
h[15]=1;
printf("C!D+");
}
if(p[0]==1&&p[1]==1&&p[4]==1&&p[5]==1&&h[0]!=1&&h[4]!=1)
{
h[16]=1;
printf("!A!C+");
}
if(p[1]==1&&p[3]==1&&p[5]==1&&p[7]==1&&h[0]!=1&&h[7]!=1)
{
h[17]=1;
printf("!AD+");
}
if(p[2]==1&&p[3]==1&&p[6]==1&&p[7]==1&&h[0]!=1&&h[5]!=1)
{
h[18]=1;
printf("!AC+");
}
if(p[0]==1&&p[2]==1&&p[4]==1&&p[6]==1&&h[0]!=1&&h[6]!=1)
{
h[19]=1;
printf("!A!D+");
}
if(p[4]==1&&p[5]==1&&p[12]==1&&p[13]==1&&h[3]!=1&&h[4]!=1)
{
h[20]=1;
printf("B!C+");
}
if(p[5]==1&&p[7]==1&&p[13]==1&&p[15]==1&&h[3]!=1&&h[7]!=1)
{
h[21]=1;
printf("BD+");
}
if(p[6]==1&&p[7]==1&&p[14]==1&&p[15]==1&&h[3]!=1&&h[5]!=1)
{
h[22]=1;
printf("BC+");
}
if(p[4]==1&&p[6]==1&&p[12]==1&&p[14]==1&&h[3]!=1&&h[6]!=1)
{
h[23]=1;
printf("B!D+");
}
if(p[8]==1&&p[9]==1&&p[12]==1&&p[13]==1&&h[1]!=1&&h[4]!=1)
{
h[24]=1;
printf("A!C+");
}
if(p[9]==1&&p[11]==1&&p[13]==1&&p[15]==1&&h[1]!=1&&h[7]!=1)
{
h[25]=1;
printf("AD+");
}
if(p[10]==1&&p[11]==1&&p[14]==1&&p[15]==1&&h[1]!=1&&h[5]!=1)
{
h[26]=1;
printf("AC+");
}
if(p[8]==1&&p[10]==1&&p[12]==1&&p[14]==1&&h[1]!=1&&h[6]!=1)
{
h[27]=1;
printf("A!D+");
}
if(p[0]==1&&p[1]==1&&p[8]==1&&p[9]==1&&h[2]!=1&&h[4]!=1)
{
h[28]=1;
printf("!B!C+");
}
if(p[1]==1&&p[3]==1&&p[9]==1&&p[11]==1&&h[2]!=1&&h[7]!=1)
{
h[29]=1;
printf("!BD+");
}
if(p[2]==1&&p[3]==1&&p[10]==1&&p[11]==1&&h[2]!=1&&h[5]!=1)
{
h[30]=1;
printf("!BC+");
}
if(p[0]==1&&p[2]==1&&p[8]==1&&p[10]==1&&h[2]!=1&&h[6]!=1)
{
h[31]=1;
printf("!B!D+");
}
if(p[0]==1&&p[1]==1&&h[8]!=1&&h[16]!=1&&h[28]!=1&&h[0]!=1&&h[2]!=1&&h[4]!=1)