C ASSIGNMENT

i need a program that prints out
1 2 3
1 2 3
1 2 3
if the input is 3

i've written this but doesnt work
#include

int main(void) {
int x;
int i;
int j;
int y = 1;
printf("Sayiyi giriniz: ");
scanf("%d", &x);
if(x < 2 || x > 40) {
return 0;
}
for(i = 0; i < x; i++) {
for(j = 0; j < x; j++) {
printf("%d", &y);
y++;
}
y = 1;
printf("\n");
}
return 0;
}


pls help...

pic to lure neckbeards

>Sayiyi giriniz

What third world shitspeak is this?

d-d-do my homework user

shish kebab mate

greetings from arabia

Looks like dirty wanabe - euro, paedophile kebab speak.

Aka Turkish

correct

if input == 3:
print(”1 2 3\n"*3}

çek git

tm

...

seems like Sup Forums changed a lot..

i'll give a shot to g/sqt/

Well, it's a direct interpretation of what he said. He should have specified that he wants it to do different things for different inputs. Or, better yet, do his own homework and actually learn something.

The user who you replied to wasn't stupid, he's just making fun of op.

here ya go buddy boy
#include
int main(void) {
int x;
int i;
int j;
scanf("%d", &x);
printf("printing that shit:\n");
if (x < 2 || x > 40) return 0;
for (i = 0; i < x; i++) {
for (j = 0; j < x; j++) {
printf("%d ", j+1);
}
printf("\n");
}
return 0;
}

hopefully you feel silly now

The printf in your loop has &y instead of just y.

Please don't shit up other boards with your 101 class questions. Spend five minutes looking at your own code and trying to understand it. You will be infinitely better off for it.

fucking hell

i was wondering why it was printing things that resemble a memory adress... fuck me

this is C#, since you're a C smartass, you'll have no problems understanding this

static void Main(string[] args)
{
Console.Write("Digite um número: ");
string input = Console.ReadLine();

int size = int.Parse(input);

for(int x = 1; x

#include

int main(void) {
int x;
int i;
int j;
int y = 1;
printf("Sayiyi giriniz: \n");
scanf("%d", &x);
printf("\n");
if(x < 2 || x > 40) {
return 0;
}
for(i = 0; i < x; i++) {
for(j = 0; j < x; j++) {
printf("%d", y);
printf(" ");
y++;
}
y = 1;
printf("\n");
}
return 0;
}


im proud of myself

thank you Sup Forumsentleman

int main(int argc, char** argv) {
if (argc > 1 && argv[0] == '3')
printf("1 2 3 1 2 3\n");
return 0;
}

I'm fucking stupid, s/argv\[0\]/argv[1]/

This program could be done in 3 lines of Python code by a literal retard after 10 minutes of an online course.

C is fucking garbage.

kek lets see you write that code

why didnt you escape the brackets in the next segment?

the best solution, obviously
pic related

You guys got universities?

not cool

>string * 3
Wtf does this work in java lol

the first part of the s/// is a regexp, and brackets have a special meaning in regexps. The second is not a regexp, it's just text for substitution. Only a $n (where n is a small integer) would have a special meaning there. So brackets need not be escaped

here
c = 3
print((" ".join(map(str,range(1,c+1)))+"\n")*c)

#include

int main(void) {
int x;
scanf("%d", &x);
if(x == 3) {
printf("1 2 3\n1 2 3\n1 2 3\n");
}
return 0;
}

kek'd

samefag

#include

int main(int argc, char *argv[]){
if(argc < 2)return 1;
if(argv[1][0] == '3')printf("1 2 3\n1 2 3\n1 2 3\n");
}

nop

fix this
printf("%d", y);

Looks even more retarded than OPs code.
This is the correct answer though.

Lol turkey sucks

EASY LEL

var number = prompt("select letter");
if (number == 3) {
print "123";
print "123";
print "123";
}

Lol you never inplemented an input scanner and you could have printed it in one line. Stay in achool

Jk you did i am drunk

what if x = 2?

>you never inplemented an input scanner
You don't know what prompt does, do you

Kill yourself, you worthless piece of shit.

Correct response,

You don't know what irony is do you?

Then you do the for loop

Lol so upset

I said jk bro lol actually read the thread

just quit if you can't get this done
holy shit

If you can not solve that issue by your own you should just give up on programming and focus on making Kebabs, Ahmed.

Had nothing better to do

#include

int main(void)
{
int num, i, count;

scanf("%d", &num);

count = num;
while (count != 0)
{
for (i = 1; i

can't multiply strings in java due to their immutable properties

>These are the kids that defend the piece of trash called C(ancer)

C is useful for some niche applications

not for general programming

what the fuck is this code?

why the if(x < 2 || x > 40)?

Scanner myScan = new Scanner(System.in);
System.out.print("Enter the number 3: ");
int three = myScan.nextInt();

System.out.println("Oh, you entered 3? Fuck you. " + 1 + " " + 2 + " " + 3);

suck my dick OP learn yourself

C stands for cancer. If you are determined to get cancer use a decent cancer like D.

import std.stdio;

void main(){
write("Enter your loop size: ");
int n;
readf(" %s", &n);
writeln();

for (int i=1; i

So readable, your superior code

nobody said it had to be readable

Spoonfeeding needs to be banned, all responses should have told OP to figure it out himself

C babbies need help

why do you need two for loops?

what's wrong with two for loops?

If you tried to commit shit like this I would bounce it back and then we'd all make fun of you during the 11:30 meeting.

O(N^2)

okay = input('enter 3')
if okay == 3 then
print('1 2 3')
print('1 2 3')
print('1 2 3')
end

Ignore me. I though the output was just one instance of "1 2 3" not multiple.

I guess he means that it would be better to construct the string first, which is linear, and then print it N times. The total runtime is going to be linear.

So what if you input 2?

>implying you can't do shitty oneliners in C
#include
int main() {
int c = 3;
for (int i=0;i