Commit 44d03905 by videid

commit

parent fc6c0c1d
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
void size(int* rows,int* columns);
void fill(int rows,int columns);
int main(void){
int rows ;
int columns ;
size(&rows,&columns);
fill(rows,columns);
return 0 ;
}
void size(int *rows,int *columns){
*rows = 0;
*columns =0 ;
while(*rows<= 0) {
printf("enter number of rows\n");
scanf("%d", rows);
}
while(*columns <= 0) {
printf("enter number of columns\n");
scanf("%d", columns);
}
printf("%d rows %d columns \n",*rows,*columns);
}
void fill(int rows,int columns){
int h;
int i;
int j;
int myArray[rows][columns];
for (i=0 ;i< rows ;i++){
for(j=0;j<columns;j++){
printf("enter number \n");
scanf("%d", &h);
myArray[i][j] = h;
}
}
for (i=0 ;i< rows ;i++){
for(j=0;j<columns;j++){
printf("%d",myArray[i][j]);
}
printf("\n");
}
}
File added
File added
File added
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
void size(int* rows,int* columns);
void fill(int rows,int columns,int(*myArray)[rows][columns]);
void print(int rows,int columns,int(*myArray)[rows][columns]);
int main(void){
int rows ;
int columns ;
int myArray[rows][columns];
size(&rows,&columns);
fill(rows,columns,&myArray[rows][columns]);
print(rows,columns,myArray[rows][columns]);
return 0 ;
}
void size(int *rows,int *columns){
*rows = 0;
*columns =0 ;
while(*rows<= 0) {
printf("enter number of rows\n");
scanf("%d", rows);
}
while(*columns <= 0) {
printf("enter number of columns\n");
scanf("%d", columns);
}
printf("%d %d",*rows,*columns);
}
void fill(int rows,int columns,int(*myArray)[rows][columns]){
int h;
int i;
int j;
for (i=0 ;i< rows ;i++){
for(j=0;j<columns;j++){
printf("enter number \n");
scanf("%d", &h);
myArray[i][j] = h;
}
}
}
void print(int rows,int columns,int myArray[rows][columns]){
for (i=0 ;i< rows ;i++){
for(j=0;j<columns;j++){
printf("%d",h);
}
printf("\n");
}
}
......@@ -26,20 +26,12 @@ int main(void) {
int h;
for (i=0 ;i< rows ;i++){
for(j=0;j<columns;j++){
myArray[i][j] = 0;
// FOR THE RANDOM VALUES
// myArray[i][j] = rand();
// FOR THE INPUT VALUES
// printf("enter number \n");
// scanf("%d", &h);
// myArray[i][j] = h;
printf("enter number \n");
scanf("%d", &h);
myArray[i][j] = h;
printf("%d",myArray[i][j]);
}
}
......
File added
No preview for this file type
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(void) {
int rows = 0;
int columns = 0;
while( rows<=0 || rows> 5) {
printf("enter number of rows\n");
scanf("%d", &rows);
}
while(columns>6 ||0 >=columns) {
printf("enter number of columns\n");
scanf("%d", &columns);
}
int i =0 ;
int h ;
int j = 0 ;
int myArray[rows][columns];
for (i=0 ;i< rows ;i++){
for(j=0;j<columns;j++){
// FOR THE RANDOM VALUES
// myArray[i][j] = rand();
printf("enter number \n");
scanf("%d", &h);
myArray[i][j] = h;
}
}
for (i=0 ;i< rows ;i++){
for(j=0;j<columns;j++){
printf("%d",myArray[i][j]);
}
printf("\n");
}
int k=2;
int B[rows];
while ( rows > k){
k++;
int e = 0 ;
int g = 0;
while (columns > e-1){
g=g + myArray[k][e];
e++;
}
printf("\n %d \n",g);
}
}
//I DONT KNOW WHY IT DEOSN T RETURN THE RIGHT SUM
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
void createarray(int*n);
void input(int n,int *arr[n]);
void func3();
int main(void){
int n ;
int arr[n] ;
createarray(&n);
input(n,&arr[n]);
}
void createarray(int *n){
*n = 0;
while (*n<2 || *n>8){
printf("enter size of the array");
scanf("%d",n);
}
}
void input(int n,int *arr[n]){
int i ;
int h = 4445;
for (i=0;i< n;i++){
while (h> 4444){
printf("enter number %d of the array",i);
scanf("d",h);
*arr[i] = 0;
*arr[i] = h;
}
}
}
void func3(){
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment